package com.mxpio.erp.plm.service.impl;

import com.mxpio.erp.common.plm.entity.ProjectInfo;
import com.mxpio.erp.common.plm.entity.ProjectInfoStatusHistory;
import com.mxpio.erp.common.plm.service.ProjectInfoStatusHistoryService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.security.service.impl.BaseServiceImpl;
import com.mxpioframework.security.util.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 项目状态历史
 * @Author qb
 *  @Date 2024-2-19
 */
@Service
public class ProjectInfoStatusHistoryServiceImpl extends BaseServiceImpl<ProjectInfoStatusHistory> implements ProjectInfoStatusHistoryService {
    /**
     *
     * 添加状态记录
     * @param proStatus
     * @param projectInfo
     */
    @Override
    @Transactional
    public void statusRecord(String proStatus, ProjectInfo projectInfo,String remark) {
        ProjectInfoStatusHistory history = new ProjectInfoStatusHistory();
        history.setProCode(projectInfo.getProCode());
        history.setProStatusBefore(proStatus);
        history.setProStatusAfter(projectInfo.getProStatus());
        history.setChangeTime(new Date());
        //设置变更人，以当前用户为变更人
        history.setChangeUser(SecurityUtils.getLoginUsername());
        //设置备注信息
        history.setRemark(remark);
        this.save(history);
    }
}
